// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.Styles;

import java.nio.FloatBuffer;
import org.lwjgl.util.ReadableColor;

public enum AlphaOp {
    PREMULTIPLY {
        @Override
        protected int calc(ReadableColor readableColor, int _int) {
            float float0 = (float)(readableColor.getAlpha() * _int) * 0.003921569F;
            float float1 = float0 * 0.003921569F;
            return (int)((float)readableColor.getRed() * float1) << 0
                | (int)((float)readableColor.getGreen() * float1) << 8
                | (int)((float)readableColor.getBlue() * float1) << 16
                | (int)float0 << 24;
        }
    },
    KEEP {
        @Override
        protected int calc(ReadableColor readableColor, int var2) {
            return readableColor.getRed() << 0 | readableColor.getGreen() << 8 | readableColor.getBlue() << 16 | readableColor.getAlpha() << 24;
        }
    },
    ZERO {
        @Override
        protected int calc(ReadableColor readableColor, int _int) {
            float float0 = (float)(readableColor.getAlpha() * _int) * 0.003921569F;
            float float1 = float0 * 0.003921569F;
            return (int)((float)readableColor.getRed() * float1) << 0
                | (int)((float)readableColor.getGreen() * float1) << 8
                | (int)((float)readableColor.getBlue() * float1) << 16;
        }
    };

    private static final float PREMULT_ALPHA = 0.003921569F;

    public final void op(ReadableColor readableColor, int _int, FloatBuffer floatBuffer) {
        floatBuffer.put(Float.intBitsToFloat(this.calc(readableColor, _int)));
    }

    public final void op(int c, int alpha, FloatBuffer dest) {
        dest.put(Float.intBitsToFloat(c));
    }

    protected abstract int calc(ReadableColor var1, int var2);
}
